<?php
declare (strict_types=1);

namespace app\common\tool;

use think\api\Client;

class Api
{
    protected $appCode = '88a4f4924a4a60cba2af54cd599af841';

    private static $_instance = null;

    public static function Instance()
    {
        if (empty(self::$_instance)) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    /**
     * 原点 2021年8月10日14:47:06 查询IP所在地
     * @param $ip -- 要查询的IP
     */
    public function queryIp($ip)
    {
        try {
            $client = new Client($this->appCode);

            return $client->ipIndex()->withIp($ip)->request();
        } catch (\Exception $e) {
            return false;
        }
    }
}